<?php 

echo $this->element('top_menu', array());

?>

<h1>user</h1>
<form action="/test_1/users/save" method="post" id="form_user_edit">
<table>
    <tr>
        <th>Login</th>
        <th>Gruppo</th>
    </tr>

	<tr>
		<td><input type="hidden" name="id" value="<?php echo $user['User']['id'];?>" />
			<input type="text" name="username" value="<?php echo $user['User']['username'];?>" /></td>
		<td>
			<select name='group_id'>
				<?foreach ($groups as $key => $group) {?>
			  			<option value='<? echo $key?>' <? if($key == $user['User']['group_id']) echo " selected='selected' " ?>  ><? echo $group ?></option>
				<? } ?> 
			</select> 
			
		</td>
	</tr>
	<tr>
		<td>
			<input type="submit" size="30" value="Conferma" />
		</td>
		<td>
			<input type="button" size="30" onclick="elimina()" value="Elimina" />
		</td>
		<td>
			<a type="button" href="/test_1/users">Esci</a>
		</td>
	</tr>

	<?php unset($user); ?> 
</table>

</form>

<script>
	function elimina() {
		$("#form_user_edit").attr("action", "/test_1/users/delete").submit(); 
	}
</script>